package com.woorigil.social.domain.flower;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Nicejinux
 * Date: 13. 7. 30.
 * Time: 오전 12:06
 * To change this template use File | Settings | File Templates.
 */

@Service
public class FlowerInfoService {
    @Autowired FlowerInfoDao flowerInfoDao;
    @Autowired FlowerSubInfoDao flowerSubInfoDao;

    public List<FlowerInfo> getAllFlowerInfo() {
        List<FlowerInfo> flowerInfoList;
        List<FlowerSubInfo> flowerSubInfoList;
        List<FlowerInfo> flowerInfoListAndSubInfoList = new ArrayList<FlowerInfo>();

        flowerInfoList = flowerInfoDao.getAllFlowerInfo();
        for (FlowerInfo flowerInfo : flowerInfoList) {
            flowerSubInfoList = flowerSubInfoDao.getFlowerSubInfoByFlowerInfoNo(flowerInfo.flowerNo);
            String subImgNames = null;
            for (FlowerSubInfo flowerSubInfo : flowerSubInfoList) {
                subImgNames = subImgNames + ":" + flowerSubInfo.subImgName;
            }
            flowerInfo.setImgSubNames(subImgNames);
            flowerInfoListAndSubInfoList.add(flowerInfo);
        }

        return flowerInfoListAndSubInfoList;
    }
}
